package cn.tedu.javacv159.client;

import cn.tedu.common.ex.ServiceException;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

@Service
@Component
@FeignClient(name = "javacv-159", path = "/api/videos", url = "http://localhost:11146")
public interface JavacvClient {
    // 防止 feign 传 MultipartFile Error converting request body 序列化 错误
    // consumes = MediaType.MULTIPART_FORM_DATA_VALUE 通过表单传送
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ApiOperation(value = "拼接")
    ResponseEntity uploadVideo(
            @RequestPart("file") MultipartFile file,
            @RequestParam("intervalTime") Double intervalTime,
            @RequestParam("direction") String direction) throws ServiceException;
}